# -*- coding: utf-8 -*-
import cocos
from cocos.director import director
import define
import DataBase
# from gluttonous import id_now

class Gameover(cocos.layer.ColorLayer):
    def __init__(self):
        over_id = 1 
        super(Gameover, self).__init__(200, 235, 235, 200, 400, 300)
        self.position = (director.get_window_size()[0] / 2 - 350,
                         director.get_window_size()[1] / 2 - 150)
        #如果下面的一行不加的话，在最开始的时候就会有结算图像在我们屏幕中间，影响宝宝们的体验
        self.visible = False
        #但是在玩家死亡时，我们就改为True,这个更改操作在gluttonous文件里(line 93)处理死亡时做了
        #快去看看吧--------HAO.2023.12.5
        #
        self.score = cocos.text.Label('',
                                      font_name='SimHei',
                                      font_size=48,
                                      color=define.MAROON)
        self.score.position = 250, 200
        self.add(self.score)
    
        text = cocos.text.Label('SCORE: ',
                                font_name='SimHei',
                                font_size=48,
                                color=define.MAROON)
        text.position = 60, 200
        self.add(text)
        text = cocos.text.Label('CLICK TO REPLAY...',
                                font_name='SimHei',
                                font_size=24,
                                color=define.MAROON)
        text.position = 60, 100
        self.add(text)
        text = cocos.text.Label('TOP RANKING',
                                font_name='SimHei',
                                font_size=48,
                                color=define.SKY_BLUE)
        text.position = 450, 400
        self.add(text)


        # DataBase.update_data(over_id, str())


        # self.text = DataBase.readf_top5_to_str()
        # lines = self.score_text.split('\n')

        line_height = 50  # 每行的高度
        self.label = [text]*12
        for i in range(12):
            self.label[i] = cocos.text.Label('',
                                    font_name='SimHei',
                                    font_size=36,
                                    color=define.SKY_BLUE)
            self.label[i].position = 350, 350 - i * line_height
            self.add(self.label[i])
        
        
        
        
        # text = cocos.text.HTMLLabel('<font face="SimHei" size="24" color="#0000FF">' + DataBase.readf_top5_to_str() + '</font>')
        # text.position = 500, 300
        # self.add(text)